//
//  LessonTableViewCell.m
//  e-Learning
//
//  Created by rimi on 16/6/22.
//  Copyright © 2016年 YJ. All rights reserved.
//

#import "LessonTableViewCell.h"

@implementation LessonTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
       
        [self.contentView addSubview:self.lessonTitle];
        [self.contentView addSubview:self.containerVu];
        [self.contentView addSubview:self.imageBtn];
        [self.contentView addSubview:self.typeTitle];
        [self.contentView addSubview:self.students];
        [self.contentView addSubview:self.star];
        [self.contentView addSubview:self.discuss];
        [self.contentView addSubview:self.teacherName];
        [self.contentView addSubview:self.learnTime];
    }
    return self;
}


- (UIView *)containerVu{
    if (!_containerVu) {
        _containerVu = [[UIView alloc] initWithFrame:CGRectMake(Screen_Width/20, Screen_Height/2*0.2, Screen_Width*0.3, Screen_Height/2*0.6)];
        _containerVu.layer.borderColor = [UIColor lightGrayColor].CGColor;
        _containerVu.layer.borderWidth = 1.5;
    }
    return _containerVu;
}

- (UIButton *)imageBtn{
    if (!_imageBtn) {
        _imageBtn = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width/20, Screen_Height/2*0.2, Screen_Width*0.3, Screen_Height/2*0.6/8*7)];
        [_imageBtn addTarget:self action:@selector(enterVideoVu) forControlEvents:UIControlEventTouchUpInside];
    }
    return _imageBtn;
}

- (UILabel *)typeTitle{
    if (!_typeTitle) {
        _typeTitle = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width/20, Screen_Height/2*0.6/8*7+Screen_Height/2*0.2, Screen_Width*0.3, Screen_Height/2*0.6/8)];
        _typeTitle.font = [UIFont systemFontOfSize:23];
    }
    return _typeTitle;
}

- (UILabel *)teacherName{
    if (!_teacherName) {
        _teacherName = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width/20, Screen_Height/2*0.8, Screen_Width*0.3*0.5, Screen_Height/2*0.2/3)];
        _teacherName.textColor = [UIColor lightGrayColor];
        _teacherName.font = [UIFont systemFontOfSize:22];
    }
    return _teacherName;
}

- (UILabel *)learnTime{
    if (!_learnTime) {
        _learnTime = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width*0.3*0.5+Screen_Width/20, Screen_Height/2*0.8, Screen_Width*0.3*0.5, Screen_Height/2*0.2/3)];
        _learnTime.textAlignment = NSTextAlignmentRight;
        _learnTime.textColor = [UIColor lightGrayColor];
        _learnTime.font = [UIFont systemFontOfSize:22];
    }
    return _learnTime;
}

- (UILabel *)students{
    if (!_students) {
        _students = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width/20, Screen_Height/2*0.867, Screen_Width*0.3*0.5, Screen_Height/2*0.2/3)];
        _students.textColor = [UIColor lightGrayColor];
        _students.font = [UIFont systemFontOfSize:21];
    }
    return _students;
}

- (UILabel *)lessonTitle{
    if (!_lessonTitle) {
        _lessonTitle = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width/20, Screen_Height/2*0.2*0.2, Screen_Width*0.3*0.5, Screen_Height/2*0.2*0.4)];
        _lessonTitle.layer.borderColor = [UIColor redColor].CGColor;
        _lessonTitle.layer.borderWidth = 1.5;
        _lessonTitle.textColor = [UIColor lightGrayColor];
        _lessonTitle.font = [UIFont systemFontOfSize:22];
        _lessonTitle.textAlignment = NSTextAlignmentCenter;
    }
    return _lessonTitle;
}

- (UILabel *)discuss{
    if (!_discuss) {
        _discuss = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width/20+Screen_Width*0.3*0.5, Screen_Height/2*0.934, Screen_Width*0.3*0.5, Screen_Height/2*0.2/3)];
        _discuss.textAlignment = NSTextAlignmentRight;
        _discuss.textColor = [UIColor lightGrayColor];
        _discuss.font = [UIFont systemFontOfSize:18];
    }
    return _discuss;
}

- (UILabel *)star{
    if (!_star) {
        _star = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width/20, Screen_Height/2*0.934, Screen_Width*0.3*0.5, Screen_Height/2*0.2/3)];
        _star.text = @"🐶🐶🐶🐶🐶";
    }
    return _star;
}



- (void)enterVideoVu{
    if (_delegate && [_delegate respondsToSelector:@selector(enterVideoVu:countLesson:)]){
        [_delegate enterVideoVu:self.videoID countLesson:self.lessonCount];
    }


}






- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
